package com.battle.service.controller.web;

import com.battle.pojo.param.studyPlanUser.*;
import com.battle.pojo.param.studyUser.GetStudyUserListParam;
import com.battle.pojo.vo.studyPlanUser.*;
import com.battle.pojo.vo.studyUser.GetStudyUserListVo;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/用户学习进度
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/studyPlanUser/web")
public class StudyPlanUserWebController {

    private final StudyPlanUserService service;
    private final StudyUserService studyUserService;

    public StudyPlanUserWebController(StudyPlanUserService service, StudyUserService studyUserService) {
        this.service = service;
        this.studyUserService = studyUserService;
    }


    /**
     * 创建用户学习进度
     *
     * @param param
     * @return
     */
    @PostMapping("/createStudyPlanUser")
    public ApiResult createStudyPlanUser(@RequestBody @Valid CreateStudyPlanUserParam param) {
        service.createStudyPlanUser(param);
        return ApiResult.ok();
    }

    /**
     * 根据用户和学习计划id获取学习进度
     * @param planId
     * @param userId
     * @return
     */
    @GetMapping("/getStudyPlanUser")
    public ApiResult<List<GetStudyPlanUserVo>> getStudyPlanUser(@RequestParam("planId") Long planId, @RequestParam("userId") Long userId) {
        List<GetStudyPlanUserVo> vo = service.getStudyPlanUser(planId, userId);
        return ApiResult.ok(vo);
    }

    /**
     * 获取学习进度列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getStudyUserList")
    public ApiResult<PageResult<GetStudyUserListVo>> getStudyUserList(@RequestBody GetStudyUserListParam param) {
        PageResult<GetStudyUserListVo> result = studyUserService.getStudyUserList(param);
        return ApiResult.ok(result);
    }


    /**
     * 根据学习计划id查看学习进度
     * @param planId
     * @return
     */
    @GetMapping("/getStudyPlanUserGraph")
    public ApiResult<List<GetStudyPlanUserGraphVo>> getStudyPlanUserGraph(@RequestParam("planId") Long planId) {
        List<GetStudyPlanUserGraphVo> vo = studyUserService.getStudyPlanUserGraph(planId);
        return ApiResult.ok(vo);
    }



}

